//package com.shop.servlet.handler;
//
//
//import org.springframework.http.HttpStatus;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.logging.ErrorManager;
//
//import com.alibaba.fastjson.JSON;
//
///**
// * 未认证处理器
// * 处理未认证的请求
// */
//@Component
//public class AuthenticationEntryPointHandler implements AuthenticationEntryPoint {
//
//    @Override
//    public void commence(HttpServletRequest request, HttpServletResponse response,
//                         AuthenticationException authException) throws IOException {
//        int code = HttpStatus.UNAUTHORIZED.value();
//        String msg = "认证失败，请先登录";
//
//        response.setStatus(code);
//        response.setContentType("application.yml/json");
//        response.setCharacterEncoding("utf-8");
//
//        PrintWriter writer = response.getWriter();
//        System.out.println(msg);
//        writer.write(JSON.toJSONString(msg));
//        writer.flush();
//        writer.close();
//    }
//}
